'use strict';

module.exports = app => {
  const { ENUM, INTEGER } = app.Sequelize;
  // 团队佣金日志
  const GroupCommissionLog = app.model.define('groupCommissionLog', {
    // 会员基本佣金
    memberBaseCommission: { type: INTEGER, allowNull: false, defaultValue: 0 },
    // 销售状态
    type: {
      type: ENUM,
      values: [
        'general',
        'member',
        'directHigher',
        'indirectHigher',
        'directFacilitator',
        'indirectFacilitator',
      ],
    },
    // 是否为同级会员
    isSameGroupCommissionClassificationWithPreviousUser: {
      type: ENUM,
      values: [ 'sibling', 'different' ],
    },
  });

  GroupCommissionLog.associate = function() {
    // 店铺
    GroupCommissionLog.belongsTo(app.model.Order);
    // 店铺
    GroupCommissionLog.belongsTo(app.model.User);
    // // 店铺
    // GroupCommissionLog.belongsTo(app.model.Store);
    // // 店铺
    // GroupCommissionLog.hasOne(app.model.OrderItem);
  };

  return GroupCommissionLog;
};
